package com.suchuang.dcs.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.suchuang.dcs.po.${bean_type_name}Param;
import com.suchuang.dcs.po.${bean_type_name};
import com.suchuang.dcs.service.Front${bean_type_name}Service;
import com.suchuang.dcs.util.ResponseResult;
import com.suchuang.dcs.util._CheckUtils;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * ${table.TABLE_COMMENT}
 * @author rengy
 */
@Controller
@Api(tags = "Front${bean_type_name}Controller", description = "${table.TABLE_COMMENT}")
@RequestMapping("/front_${model_code}")
public class Front${bean_type_name}Controller {
    @Autowired
    private Front${bean_type_name}Service front${bean_type_name}Service;

    
    
    @ApiOperation(value = "查询所有${table.TABLE_COMMENT}")
    @RequestMapping(value = "/listAll", method = RequestMethod.POST)
    @ResponseBody
    public ResponseResult listAll(@RequestBody(required = false) ${bean_type_name}Param param) {
    	//_CheckUtils.checkNull(param, "");
    	ResponseResult result=new ResponseResult();
    	if(param==null) {
    		param=new ${bean_type_name}Param();
    	}
    	param.setIsPaging(false);
    	result.setData(front${bean_type_name}Service.select(param));
    	return result;
    }
    
    @ApiOperation(value = "分页查询${table.TABLE_COMMENT}")
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public ResponseResult list(@RequestBody(required = false) ${bean_type_name}Param param) {
    	//_CheckUtils.checkNull(param, "");
    	ResponseResult result=new ResponseResult();
    	if(param==null) {
    		param=new ${bean_type_name}Param();
    	}
    	param.setIsPaging(true);
    	result.setData(front${bean_type_name}Service.select(param));
    	return result;
    }

	@ApiOperation(value = "${table.TABLE_COMMENT}详情")
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    @ResponseBody
    public ResponseResult get(@RequestBody ${bean_type_name}Param param) {
    	_CheckUtils.checkNull(param, "id");
    	ResponseResult result=new ResponseResult();
    	${bean_type_name} record=front${bean_type_name}Service.get(param.getId());
    	result.setData(record);
    	return result;
    }
    @ApiOperation(value = "新增${table.TABLE_COMMENT}")
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    @ResponseBody
    public ResponseResult create(@RequestBody ${bean_type_name}Param param) {
    	ResponseResult result=new ResponseResult();
    	front${bean_type_name}Service.insert(param);
    	result.setData(null);
    	return result;
    }

    @ApiOperation(value = "修改${table.TABLE_COMMENT}")
    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ResponseBody
    public ResponseResult update(@RequestBody ${bean_type_name}Param param) {
    	ResponseResult result=new ResponseResult();
    	front${bean_type_name}Service.updateByPrimaryKeySelective(param);
    	result.setData(null);
    	return result;
    }

    @ApiOperation(value = "删除${table.TABLE_COMMENT}")
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseBody
    public ResponseResult delete(@RequestBody ${bean_type_name}Param param) {
    	ResponseResult result=new ResponseResult();
    	front${bean_type_name}Service.deleteByPrimaryKey(param.getId());
    	result.setData(null);
    	return result;
    }
}
